<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>职位管理</title>
    <link rel='stylesheet prefetch' href='/dev/assets/css/distributed/reset.css'>
    <link rel="stylesheet" type="text/css" href="/dev/assets/css/distributed/default.css">
    <link rel="stylesheet" type="text/css" href="/dev/assets/css/distributed/styles.css">
    <link rel="stylesheet" href="/dev/plugins/layui/layui/css/layui.css">
    <link rel="icon" href="/dev/assets/img/geek-job/wanli.jpg" type="image/x-icon">
    <script>
        e();
        function e () {
            // 在这里执行条件检查
            let token = localStorage.getItem("jrtoken")
            if (token==null) {
                // 执行页面跳转
                window.location.href = '/dev/views/job/page/login.html';
            }
        }
    </script>
</head>

<body>
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black">职途万里</div>
        <!-- 头部区域（可配合layui 已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <!-- 移动端显示 -->
            <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
                <i class="layui-icon layui-icon-spread-left"></i>
            </li>
            <li class="layui-nav-item layui-hide-xs"><a href="/dev/views/employment/chat.html"><i class="layui-icon layui-icon-notice"></i></a>
            </li>
            <li class="layui-nav-item layui-hide-xs"><a href="javascript:;">我的客服</a></li>
            <li class="layui-nav-item layui-hide-xs"><a href="javascript:;">面试</a></li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide layui-show-sm-inline-block">
                <a href="javascript:;" id="jr_username">
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="javascript:;">个人资料</a></dd>
                    <dd><a href="javascript:;">设置</a></dd>
                    <dd><a href="javascript:quit();">退出</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
                <a href="javascript:;">
                    <i class="layui-icon layui-icon-more-vertical"></i>
                </a>
            </li>
        </ul>
    </div>
    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-item layui-nav-itemed">
                    <a id="pmg" href="/dev/views/employment/index.html"><i class="layui-icon layui-icon-form"></i> 职位管理</a>
                </li>
                <li class="layui-nav-item">
                    <a href="/dev/views/employment/searchperson.html"><i class="layui-icon layui-icon-search"></i> 搜索牛人</a>

                </li>
                <li class="layui-nav-item"><a href="/dev/views/employment/recommend.html"><i class="layui-icon layui-icon-user"></i> 推荐牛人</a></li>
                <li class="layui-nav-item"><a href="/dev/views/employment/chat.html"><i class="layui-icon layui-icon-chat"></i> 沟通</a></li>
            </ul>
        </div>
    </div>
    <div class="layui-body" id="employment-body">
        <!-- 内容主体区域 -->
        <div style="padding: 15px;">
            <blockquote class="layui-elem-quote layui-text">
                职位管理
            </blockquote>
            <div style="padding: 16px;">
                <table class="layui-hide" id="test" lay-filter="test"></table>
            </div>
            <div id="main" style="width: 1200px;height:400px;"></div>
            <script type="text/html" id="toolbarDemo">
                <div class="layui-btn-container">
                    <button class="layui-btn layui-btn-sm" lay-event="getCheckData">当前行职位信息</button>
                    <button class="layui-btn layui-btn-sm" lay-event="getData">当前页职位信息</button>
                    <button class="layui-btn layui-btn-sm" id="dropdownButton">
                        发布/修改/删除职位
                        <i class="layui-icon layui-icon-down layui-font-12"></i>
                    </button>
                    <!--                    <button class="layui-btn layui-btn-sm layui-bg-blue" id="reloadTest">-->
                    <!--                        重载测试-->
                    <!--                        <i class="layui-icon layui-icon-down layui-font-12"></i>-->
                    <!--                    </button>-->
                    <button class="layui-btn layui-btn-sm layui-btn-primary" id="rowMode">
                        <span>{{= d.lineStyle ? '多行' : '单行' }}模式</span>
                        <i class="layui-icon layui-icon-down layui-font-12"></i>
                    </button>
                </div>
            </script>
            <script type="text/html" id="barDemo">
                <div class="layui-clear-space">
                    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                    <a class="layui-btn layui-btn-xs" lay-event="more">
                        更多
                        <i class="layui-icon layui-icon-down"></i>
                    </a>
                </div>
            </script>
        </div>
<!--        <div class="layui-footer">-->
<!--            &lt;!&ndash; 底部固定区域 &ndash;&gt;-->
<!--            公告:高贤甫-->
<!--        </div>-->
    </div>
</div>
<!--<script src="/dev/plugins/jquery/jquery.min.js"></script>-->
<script src="/dev/plugins/jquery/jquery-2.1.1.min.js"></script>
<!--主导的js包-->
<script src="/dev/plugins/jquery/jquery.easing.min.js" type="text/javascript"></script>

<script src="/dev/plugins/layui/layui/layui.js"></script>

<script>
    //JS
    layui.use(['element', 'layer', 'util'], function () {
        var element = layui.element;
        var layer = layui.layer;
        var util = layui.util;
        var $ = layui.$;

        //头部事件
        util.event('lay-header-event', {
            menuLeft: function (othis) { // 左侧菜单事件
                layer.msg('展开左侧菜单的操作', { icon: 0 });
            },
            menuRight: function () {  // 右侧菜单事件
                layer.open({
                    type: 1,
                    title: '更多',
                    content: '<div style="padding: 15px;">处理右侧面板的操作</div>',
                    area: ['260px', '100%'],
                    offset: 'rt', // 右上角
                    anim: 'slideLeft', // 从右侧抽屉滑出
                    shadeClose: true,
                    scrollbar: false
                });
            }
        });
    });
</script>
<script>
    layui.use(function () {
        var dropdown = layui.dropdown;
        // 渲染
        dropdown.render({
            elem: '.demo-dropdown-base', // 绑定元素选择器，此处指向 class 可同时绑定多个元素
            data: [{
                title: 'menu item 1',
                id: 100
            }, {
                title: 'menu item 2',
                id: 101
            }, {
                title: 'menu item 3',
                id: 102
            }],
            click: function (obj) {
                this.elem.find('span').text(obj.title);
            }
        });
    });
</script>
<script>
    layui.use(['table', 'dropdown'], function(){
        var table = layui.table;
        var dropdown = layui.dropdown;
        var jrId = localStorage.getItem("jrid")

        // 创建渲染实例
        table.render({
            headers:{
                "id":localStorage.getItem("jrid"),
                "token":localStorage.getItem("jrtoken")
            },
            elem: '#test',
            limit: 4,
            limits: [4, 6, 8, 10],
            url: `/dev/employment/page?jrId=${jrId}`, // 此处为静态模拟数据，实际使用时需换成真实接口
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            height: 'full-35', // 最大高度减去其他容器已占有的高度差
            css: [ // 重设当前表格样式
                '.layui-table-tool-temp{padding-right: 145px;}'
            ].join(''),
            cellMinWidth: 80,
            page: true,
            cols: [[
                {type: 'checkbox', fixed: 'left'},
                {field:'posName', fixed: 'left', width:80, title: '职位'},
                {field:'posType', width:100, title: '职位类型'},
                {field:'posDescription', title:'职位描述 <i class="layui-icon layui-icon-tips layui-font-14" lay-event="email-tips" title="该字段开启了编辑功能" style="margin-left: 5px;"></i>', fieldTitle: '职位描述', hide: 0, width:150, expandedMode: 'tips', edit: 'text'},
                {field:'posKeyword', width:80, title: '职位关键字'},
                {field:'workPlace', width:80, title: '工作地点'},
                {field:'recruitsNum', title:'招聘人数 <i class="layui-icon layui-icon-tips layui-font-14" lay-event="email-tips" title="该字段开启了编辑功能" style="margin-left: 5px;"></i>', fieldTitle: '招聘人数', hide: 0, width:100, expandedMode: 'tips', edit: 'text'},
                {field:'payFloor', title:'薪资下限 <i class="layui-icon layui-icon-tips layui-font-14" lay-event="email-tips" title="该字段开启了编辑功能" style="margin-left: 5px;"></i>', fieldTitle: '薪资下限', hide: 0, width:100, expandedMode: 'tips', edit: 'text'},
                {field:'payUpper', title:'薪资上限 <i class="layui-icon layui-icon-tips layui-font-14" lay-event="email-tips" title="该字段开启了编辑功能" style="margin-left: 5px;"></i>', fieldTitle: '薪资上限', hide: 0, width:100, expandedMode: 'tips', edit: 'text'},
                {field:'specialty', title:'专业要求 <i class="layui-icon layui-icon-tips layui-font-14" lay-event="email-tips" title="该字段开启了编辑功能" style="margin-left: 5px;"></i>', fieldTitle: '专业要求', hide: 0, width:150, expandedMode: 'tips', edit: 'text'},
                {field:'sexDemand', title:'性别要求 <i class="layui-icon layui-icon-tips layui-font-14" lay-event="email-tips" title="该字段开启了编辑功能" style="margin-left: 5px;"></i>', fieldTitle: '性别要求', hide: 0, width:150, expandedMode: 'tips', edit: 'text'},
                {field:'expDemand', title:'工作经验要求 <i class="layui-icon layui-icon-tips layui-font-14" lay-event="email-tips" title="该字段开启了编辑功能" style="margin-left: 5px;"></i>', fieldTitle: '工作经验要求', hide: 0, width:150, expandedMode: 'tips', edit: 'text'},
                {field:'ageDemand', title:'年龄要求 <i class="layui-icon layui-icon-tips layui-font-14" lay-event="email-tips" title="该字段开启了编辑功能" style="margin-left: 5px;"></i>', fieldTitle: '年龄要求', hide: 0, width:100, expandedMode: 'tips', edit: 'text'},
                {field:'jobBenefits', title:'职位福利 <i class="layui-icon layui-icon-tips layui-font-14" lay-event="email-tips" title="该字段开启了编辑功能" style="margin-left: 5px;"></i>', fieldTitle: '职位福利', hide: 0, width:100, expandedMode: 'tips', edit: 'text'},
                {field:'posTelephone', title:'联系电话 <i class="layui-icon layui-icon-tips layui-font-14" lay-event="email-tips" title="该字段开启了编辑功能" style="margin-left: 5px;"></i>', fieldTitle: '联系电话', hide: 0, width:100, expandedMode: 'tips', edit: 'text'},
                {field:'posEmail', title:'邮箱 <i class="layui-icon layui-icon-tips layui-font-14" lay-event="email-tips" title="该字段开启了编辑功能" style="margin-left: 5px;"></i>', fieldTitle: '邮箱', hide: 0, width:100, expandedMode: 'tips', edit: 'text'},
                {field:'publishTime', width:120, title: '发布时间'},
                {field:'publishStatus', width:100, title: '发布状态'},
                {field:'publishCycle', width:100, title: '发布周期'},
                {fixed: 'right', title:'操作', width: 134, minWidth: 125, toolbar: '#barDemo'}
            ]],
            done: function(){
                var id = this.id;
                // 下拉按钮测试
                dropdown.render({
                    elem: '#dropdownButton', // 可绑定在任意元素中，此处以上述按钮为例
                    data: [{
                        id: 'add',
                        title: '发布新职位'
                    },{
                        id: 'update',
                        title: '更新选中职位'
                    },{
                        id: 'delete',
                        title: '删除选中职位'
                    }],
                    // 菜单被点击的事件
                    click: function(obj){
                        var checkStatus = table.checkStatus(id)
                        var data = checkStatus.data; // 获取选中的数据
                        switch(obj.id){
                            case 'add':
                                layer.open({
                                    title: '发布新职位',
                                    type: 1,
                                    area: ['80%','80%'],
                                    content: `
<article class="htmleaf-content">
    <!-- multistep form -->
    <form id="msform">
        <!-- progressbar -->
        <ul id="progressbar">
            <li class="active">职位信息填写</li>
            <li>职位详细信息信息</li>
            <li>公司详细信息</li>
            <li>公司其他信息</li>
        </ul>
        <!-- fieldsets -->
        <fieldset>
            <h2 class="fs-title">选择发布职位的基本信息</h2>
            <h3 class="fs-subtitle">这是第一步</h3>
            <input type="hidden" name="jrId" value="${jrId}">
            <input type="text" name="posName" id="posName" placeholder="输入职位名"  />
            <input type="text" name="posType" id="posType" placeholder="请输入职位类型" />
            <textarea name="posDescription" id="posDescription" placeholder="职位描述"></textarea>
            <input type="text" name="posKeyword" id="posKeyword" placeholder="请输入职位关键字" />

            <input type="button" name="next" id="next" class="next action-button"  value="Next" />
        </fieldset>
        <fieldset>
            <h2 class="fs-title">填写详细信息</h2>
            <h3 class="fs-subtitle">填写你要发布职位的详细信息</h3>
            <textarea name="workPlace" id="workPlace" placeholder="公司地址"></textarea>
            <input type="text" name="recruitsNum" id="recruitsNum"  placeholder="请输入招聘人数" />
            <input type="text" name="payFloor"  id="payFloor" placeholder="请输入薪资下限" />
            <input type="text" name="payUpper" id="payUpper" placeholder="请输入薪资上限" />
            <input type="button" name="previous" class="previous action-button" value="Previous">
            <input type="button" name="next" class="next action-button" id="next2"  value="Next"/>
        </fieldset>
        <fieldset>
            <h2 class="fs-title">公司要求</h2>
            <h3 class="fs-subtitle">输入您对求职者的一些要求</h3>
            <input type="text" name="background" id="background" placeholder="请输入学历要求" />
            <input type="text" name="specialty"  id="specialty" placeholder="请输入专业要求" />
            <input type="text" name="sexDemand" id="sexDemand" placeholder="请输入性别要求" />
            <input type="text" name="expDemand" id="expDemand"  placeholder="请输入工作经验要求" />
            <input type="text" name="ageDemand" id="ageDemand" placeholder="请输入年龄要求" />
            <input type="button" name="previous" class="previous action-button"  value="Previous" />
            <input type="button" name="next" class="next action-button"   value="Next"/>
        </fieldset>

        <fieldset>
            <h2 class="fs-title">其他信息</h2>
            <h3 class="fs-subtitle">输入其他信息来吸引招聘者</h3>
            <textarea name="jobBenefits" id="desc" placeholder="职位福利"></textarea>
            <input type="text" name="recruitmentAgency" id="recruitmentAgency" placeholder="代招公司" />
            <input type="text" name="posTelephone" id="posTelephone" placeholder="请输入联系电话" />
            <input type="text" name="posEmail" id="posEmail"  placeholder="请输入联系邮箱" />
<!--            <input type="text" name="pos-publishStatus"  placeholder="开始时间" />-->
<!--            <input type="text"  id="publishCycle" placeholder="yyyy-MM-dd " name="publishCycle">-->
            <input type="text" class="layui-input" id="publishCycle" placeholder="yyyy-MM-dd" name="publishCycle">
            <input type="button" name="previous" class="previous action-button"  value="Previous" />
            <button type="button" class="layui-btn"  lay-submit="" lay-filter="demo1" onclick="add()">立即提交</button>
        </fieldset>
    </form>
</article>`
                                });
                                layui.use(function(){
                                    var laydate = layui.laydate;
                                    // 渲染
                                    laydate.render({
                                        elem: '#publishCycle',
                                        format: 'yyyy-MM-dd ',
                                    });
                                    // 英文版
                                    laydate.render({
                                        elem: '#publishCycle',
                                        format: 'yyyy-MM-dd ',
                                    });
                                });
                                var current_fs, next_fs, previous_fs;
                                var left, opacity, scale;
                                var animating;
                                $('.next').click(function () {
                                    if (animating)
                                        return false;
                                    animating = true;
                                    current_fs = $(this).parent();
                                    console.log(this)
                                    next_fs = $(this).parent().next();
                                    $('#progressbar li').eq($('fieldset').index(next_fs)).addClass('active');
                                    next_fs.show();

                                    current_fs.animate({ opacity: 0 }, {
                                        step: function (now, mx) {
                                            scale = 1 - (1 - now) * 0.2;
                                            left = now * 50 + '%';
                                            opacity = 1 - now;
                                            current_fs.css({ 'transform': 'scale(' + scale + ')' });
                                            next_fs.css({
                                                'left': left,
                                                'opacity': opacity
                                            });
                                        },
                                        duration: 800,
                                        complete: function () {
                                            current_fs.hide();
                                            animating = false;
                                        },
                                        easing: 'easeInOutBack'
                                    });
                                });
                                $('.previous').click(function () {
                                    if (animating)
                                        return false;
                                    animating = true;
                                    current_fs = $(this).parent();
                                    previous_fs = $(this).parent().prev();
                                    $('#progressbar li').eq($('fieldset').index(current_fs)).removeClass('active');
                                    previous_fs.show();
                                    current_fs.animate({ opacity: 0 }, {
                                        step: function (now, mx) {
                                            scale = 0.8 + (1 - now) * 0.2;
                                            left = (1 - now) * 50 + '%';
                                            opacity = 1 - now;
                                            current_fs.css({ 'left': left });
                                            previous_fs.css({
                                                'transform': 'scale(' + scale + ')',
                                                'opacity': opacity
                                            });
                                        },
                                        duration: 800,
                                        complete: function () {
                                            current_fs.hide();
                                            animating = false;
                                        },
                                        easing: 'easeInOutBack'
                                    });
                                });
                                // $('.layui-btn').click(function () {
                                //     return false;
                                // });
                                break;
                            case 'update':
                                console.log(data)
                                if(data.length !== 1) return layer.msg('请选择一行');
                                layer.open({
                                    title: '编辑',
                                    type: 1,
                                    area: ['80%','80%'],
                                    content: `<div class="layui-container-fiuld layui-col-md-offset3" style="width: 500px;">
    <div class="layui-row">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
            <legend id="toptitle">更新当前职位</legend>
        </fieldset>
    </div>
</div>
<div class="layui-container-fiuld">
    <div class="layui-row layui-col-md-offset3" style="width: 500px;height: 300px;">
        <form class="layui-form" lay-filter="example" id="form">
            <div class="layui-form-item">
                <label class="layui-form-label">职位</label>
                <div class="layui-input-block">
                    <input type="hidden" name="id" value="${data[0].id}">
                    <input type="hidden" name="jrId" value="${jrId}">
                    <input type="text" name="posName" id="posName" value="${data[0].posName}" lay-verify="title" autocomplete="off"
                           placeholder="请输入职位名" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">职位类型</label>
                <div class="layui-input-block">
                    <input type="text" name="posType" id="posType" value="${data[0].posType}" lay-verify="title" autocomplete="off"
                           placeholder="请输入职位类型" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">职位描述</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入内容" class="layui-textarea" name="posDescription" id="posDescription">${data[0].posDescription}</textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">职位关键字</label>
                <div class="layui-input-block">
                    <input type="text" name="posKeyword" id="posKeyword" lay-verify="title" autocomplete="off"placeholder="职位关键字" class="layui-input" value="${data[0].posKeyword}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">工作地址</label>
                <div class="layui-input-block">
                 <input type="text" name="workPlace" id="workPlace" value="${data[0].workPlace}" lay-verify="title" autocomplete="off"placeholder="请输入工作地址" class="layui-input">
                 </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">招聘人数</label>
                <div class="layui-input-block">
                    <input type="text" name="recruitsNum" id="recruitsNum" value="${data[0].recruitsNum}" lay-verify="title" autocomplete="off"placeholder="请输入招聘的人数" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">薪资下限</label>
                <div class="layui-input-block">
                    <input type="text" name="payFloor" id="payFloor" value="${data[0].payFloor}" lay-verify="title" autocomplete="off"placeholder="请输入薪资下限" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">薪资上限</label>
                <div class="layui-input-block">
                    <input type="text" name="payUpper" id="payUpper" value="${data[0].payUpper}" lay-verify="title" autocomplete="off"placeholder="请输入薪资上限" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">文化背景</label>
                <div class="layui-input-block">
                <input type="text" name="background" id="background" value="${data[0].background}" lay-verify="title" autocomplete="off"placeholder="请输入文化背景要求" class="layui-input">
                </div>
            <div class="layui-form-item">
                <label class="layui-form-label">专业要求</label>
                <div class="layui-input-block">
                <input type="text" name="specialty" id="specialty" value="${data[0].specialty}" lay-verify="title" autocomplete="off"placeholder="请输入专业要求" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">性别要求</label>
                <div class="layui-input-block">
                <input type="text" name="sexDemand" id="sexDemand" value="${data[0].sexDemand}" lay-verify="title" autocomplete="off"placeholder="请输入性别要求" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label class="layui-form-label">工作经验要求</label>
                <div class="layui-input-block">
                <input type="text" name="expDemand" id="expDemand" value="${data[0].expDemand}" lay-verify="title" autocomplete="off"placeholder="请输入工作经验要求" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">年龄要求</label>
                <div class="layui-input-block">
                <input type="text" name="ageDemand" id="ageDemand" value="${data[0].ageDemand}" lay-verify="title" autocomplete="off"placeholder="请输入年龄要求" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">职位福利</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入内容" class="layui-textarea" name="jobBenefits" id="jobBenefits">${data[0].jobBenefits}</textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">代招公司</label>
                <div class="layui-input-block">
                <input type="text" name="recruitmentAgency" id="recruitmentAgency" value="${data[0].recruitmentAgency}" lay-verify="title" autocomplete="off"placeholder="请输入代招公司" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">联系电话</label>
                <div class="layui-input-block">
                <input type="text" name="posTelephone" id="posTelephone" value="${data[0].posTelephone}" lay-verify="title" autocomplete="off"placeholder="请输入联系电话" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-block">
                <input type="text" name="posEmail" id="posEmail" value="${data[0].posEmail}" lay-verify="title" autocomplete="off"placeholder="请输入邮箱" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">截止时间</label>
              <div class="layui-input-inline">
                <input type="text" class="layui-input" id="publishCycle" placeholder="请选择截止日期" name="publishCycle" value="${data[0].publishCycle.toLocaleString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' })}">
              </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="button" class="layui-btn" lay-submit="" lay-filter="demo1" onclick="update()">立即提交</button>
                </div>
            </div>
        </form>
    </div>
</div>`
                                });
                                layui.use(function(){
                                    var laydate = layui.laydate;
                                    // 渲染
                                    laydate.render({
                                        elem: '#publishCycle',
                                        format: 'yyyy-MM-dd ',
                                    });
                                    // 英文版
                                    laydate.render({
                                        elem: '#publishCycle',
                                        lang: 'en',
                                        format: 'yyyy-MM-dd',
                                    });
                                });
                                break;
                            case 'delete':
                                if(data.length === 0){
                                    return layer.msg('请选择一行');
                                }
                                console.log("++++++++")
                                console.log(data)
                                let id=data[0].id
                                console.log(id)
                                $.ajax({
                                    headers:{
                                      "id":localStorage.getItem("jrid"),
                                      "token":localStorage.getItem("jrtoken")
                                    },
                                    url: '/dev/employment/delete',
                                    type:"POST",
                                    data: {
                                        "id":id
                                    },
                                    success:function (result){
                                        if (result.code==200){
                                            alert("删除成功")// 删除对应行（tr）的DOM结构
                                            window.location='/dev/views/employment/index.html'
                                            layer.close();
                                        }else {
                                            layer.close();
                                        }
                                    }
                                })

                                break;
                        }
                    }
                });

                // 重载测试
                dropdown.render({
                    elem: '#reloadTest', // 可绑定在任意元素中，此处以上述按钮为例
                    data: [{
                        id: 'reload',
                        title: '重载'
                    },{
                        id: 'reload-deep',
                        title: '重载 - 参数叠加'
                    },{
                        id: 'reloadData',
                        title: '仅重载数据'
                    },{
                        id: 'reloadData-deep',
                        title: '仅重载数据 - 参数叠加'
                    }],
                    // 菜单被点击的事件
                    click: function(obj){
                        switch(obj.id){
                            case 'reload':
                                // 重载 - 默认（参数重置）
                                table.reload('test', {
                                    where: {
                                        abc: '123456',
                                        //test: '新的 test2',
                                        //token: '新的 token2'
                                    },
                                    /*
                                    cols: [[ // 重置表头
                                      {type: 'checkbox', fixed: 'left'},
                                      {field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true, totalRowText: '合计：'},
                                      {field:'sex', title:'性别', width:80, edit: 'text', sort: true},
                                      {field:'experience', title:'积分', width:80, sort: true, totalRow: true, templet: '<div>{{= d.experience }} 分</div>'},
                                      {field:'logins', title:'登入次数', width:100, sort: true, totalRow: true},
                                      {field:'joinTime', title:'加入时间', width:120}
                                    ]]
                                    */
                                });
                                break;
                            case 'reload-deep':
                                // 重载 - 深度（参数叠加）
                                table.reload('test', {
                                    where: {
                                        abc: 123,
                                        test: '新的 test1'
                                    },
                                    //defaultToolbar: ['print'], // 重载头部工具栏右侧图标
                                    //cols: ins1.config.cols
                                }, true);
                                break;
                            case 'reloadData':
                                // 数据重载 - 参数重置
                                table.reloadData('test', {
                                    where: {
                                        abc: '123456',
                                        //test: '新的 test2',
                                        //token: '新的 token2'
                                    },
                                    scrollPos: 'fixed',  // 保持滚动条位置不变 - v2.7.3 新增
                                    height: 2000, // 测试无效参数（即与数据无关的参数设置无效，此处以 height 设置无效为例）
                                    //url: '404',
                                    //page: {curr: 1, limit: 30} // 重新指向分页
                                });
                                break;
                            case 'reloadData-deep':
                                // 数据重载 - 参数叠加
                                table.reloadData('test', {
                                    where: {
                                        abc: 123,
                                        test: '新的 test1'
                                    }
                                }, true);
                                break;
                        }
                        layer.msg('可观察 Network 请求参数的变化');
                    }
                });

                // 行模式
                dropdown.render({
                    elem: '#rowMode',
                    data: [{
                        id: 'default-row',
                        title: '单行模式（默认）'
                    },{
                        id: 'multi-row',
                        title: '多行模式'
                    }],
                    // 菜单被点击的事件
                    click: function(obj){
                        var checkStatus = table.checkStatus(id)
                        var data = checkStatus.data; // 获取选中的数据
                        switch(obj.id){
                            case 'default-row':
                                table.reload('test', {
                                    lineStyle: null // 恢复单行
                                });
                                layer.msg('已设为单行');
                                break;
                            case 'multi-row':
                                table.reload('test', {
                                    // 设置行样式，此处以设置多行高度为例。若为单行，则没必要设置改参数 - 注：v2.7.0 新增
                                    lineStyle: 'height: 95px;'
                                });
                                layer.msg('即通过设置 lineStyle 参数可开启多行');
                                break;
                        }
                    }
                });
            },
            error: function(res, msg){
                console.log(res, msg)
            }
        });

        // 工具栏事件
        table.on('toolbar(test)', function(obj){
            var id = obj.config.id;
            var checkStatus = table.checkStatus(id);
            var othis = lay(this);
            switch(obj.event){
                case 'getCheckData':
                    var data = checkStatus.data;
                    layer.alert(layui.util.escape(JSON.stringify(data)));
                    break;
                case 'getData':
                    var getData = table.getData(id);
                    console.log(getData);
                    layer.alert(layui.util.escape(JSON.stringify(getData)));
                    break;
                case 'LAYTABLE_TIPS':
                    layer.alert('自定义工具栏图标按钮');
                    break;
            };
        });
        // 表头自定义元素工具事件 --- 2.8.8+
        table.on('colTool(test)', function(obj){
            var event = obj.event;
            console.log(obj);
            if(event === 'email-tips'){
                layer.alert(layui.util.escape(JSON.stringify(obj.col)), {
                    title: '当前列属性配置项'
                });
            }
        });

        // 触发单元格工具事件
        table.on('tool(test)', function(obj){ // 双击 toolDouble
            var data = obj.data; // 获得当前行数据
            // console.log(obj)
            if(obj.event === 'edit'){
                layer.open({
                    title: '编辑 - id:'+ data.id,
                    type: 1,
                    area: ['80%','80%'],
                    content: '<div style="padding: 16px;">自定义表单元素</div>'
                });
            } else if(obj.event === 'more'){
                // 更多 - 下拉菜单
                dropdown.render({
                    elem: this, // 触发事件的 DOM 对象
                    show: true, // 外部事件触发即显示
                    data: [{
                        title: '查看',
                        id: 'detail'
                    },{
                        title: '删除',
                        id: 'del'
                    }],
                    click: function(menudata){
                        if(menudata.id === 'detail'){
                            layer.msg('查看操作，当前行 ID:'+ data.id);
                        } else if(menudata.id === 'del'){
                            layer.confirm('真的删除行 [id: '+ data.id +'] 么', function(index){
                                let id = data.id
                                $.ajax({
                                    headers:{
                                      "id":localStorage.getItem("jrid"),
                                      "token":localStorage.getItem("jrtoken")
                                    },
                                    url: '/dev/employment/delete',
                                    type:"POST",
                                    data: {id},
                                    success:function (result){
                                        if (result.code==200){
                                            alert("删除成功")
                                            obj.del(); // 删除对应行（tr）的DOM结构
                                            layer.close(index);
                                        }else {
                                            console.log(id)
                                            layer.close(index);
                                        }
                                    }

                                })
                                // obj.del(); // 删除对应行（tr）的DOM结构
                                // layer.close(index);
                                // // 向服务端发送删除指令
                            });
                        }
                    },
                    align: 'right', // 右对齐弹出
                    style: 'box-shadow: 1px 1px 10px rgb(0 0 0 / 12%);' // 设置额外样式
                })
            }
        });

        // 触发表格复选框选择
        table.on('checkbox(test)', function(obj){
            console.log(obj)
        });

        // 触发表格单选框选择
        table.on('radio(test)', function(obj){
            console.log(obj)
        });

        // 行单击事件
        table.on('row(test)', function(obj){
            //console.log(obj);
            //layer.closeAll('tips');
        });
        // 行双击事件
        table.on('rowDouble(test)', function(obj){
            console.log(obj);
        });

        // 单元格编辑事件
        table.on('edit(test)', function(obj){
            var field = obj.field; // 得到字段
            var value = obj.value; // 得到修改后的值
            var data = obj.data; // 得到所在行所有键值
            // 值的校验
            if(field === 'email'){
                if(!/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(obj.value)){
                    layer.tips('输入的邮箱格式不正确，请重新编辑', this, {tips: 1});
                    return obj.reedit(); // 重新编辑 -- v2.8.0 新增
                }
            }
            // 编辑后续操作，如提交更新请求，以完成真实的数据更新
            // …
            layer.msg('编辑成功', {icon: 1});

            // 其他更新操作
            var update = {};
            update[field] = value;
            obj.update(update);
        });
    });

    function add(){
        console.log("====")
        console.log($("#msform").serializeArray())
        const post = $("#msform").serializeArray()

        $.ajax({
            headers:{
                "id":localStorage.getItem("jrid"),
                "token":localStorage.getItem("jrtoken")
            },
            url: '/dev/employment/save',
            type:"POST",
            data: post,
            dataType:"json",
            success:function (result){
                if (result.code==200){
                    alert("发布成功")
                    window.location='/dev/views/employment/index.html'
                }
            }

        })
    }
    function update() {
        console.log("===")
        $.ajax({
            headers:{
                "id":localStorage.getItem("jrid"),
                "token":localStorage.getItem("jrtoken")
            },
            url:"/dev/employment/update",
            type:"post",
            data:$("#form").serializeArray(),
            dataType: "json",
            success:function (result){
                if (result.code==200){
                    alert("更新成功")
                    window.location='/dev/views/employment/index.html'
                }else{
                    alert("更新失败")
                }
            }
        })
    }



    function del(){


    }
</script>
<script>

</script>

<script>
    $(function () {
        let pmg = document.querySelector("#pmg")
        let body = document.querySelector(".layui-body")
        let uname = document.querySelector("#jr_username")
        uname.innerHTML = `<img src="/dev/assets/img/head_photo.png" class="layui-nav-img">
                    Tom`
        pmg.className = 'layui-nav-item layui-nav-itemed layui-this'
    })
    // function recommend(){
    //     let employment = document.querySelector("#employment-body")
    //     employment.innerHTML=`/dev/views/employment/recommend.html`
    // }
    function quit(){
        localStorage.removeItem("jrid");
        localStorage.removeItem("jrtoken");
        window.location='/dev/views/job/page/login.html'
    }
</script>


</body>
</html>